﻿using System;
using System.Windows.Forms;
using SurfaceAreaPresenter;
using SurfaceAreaInfrastructure;

namespace View
{
    public partial class View : Form, ISurfaceAreaView
    {
        public bool edgeLabelVisible
        {
            set
            {
                edgeLabel.Visible = value;
            }
        }

        public bool radiusLabelVisible
        {
            set
            {
                radiusLabel.Visible = value;
            }
        }

        public bool directionLabelVisible
        {
            set
            {
                directionLabel.Visible = value;
            }
        }

        public bool edgeTextFieldVisible
        {
            set
            {
                edgeTextBox.Visible = value;
            }
        }

        public bool radiusTextFieldVisible
        {
            set
            {
                radiusTextBox.Visible = value;
            }
        }

        public bool directionTextFieldVisible
        {
            set
            {
                directionTextBox.Visible = value;
            }
        }

        public bool resultButtonVisible
        {
            set
            {
                resultButton.Visible = value;
            }
        }

        public bool resultTextFieldVisible
        {
            set
            {
                resultTextBox.Visible = value;
            }
        }

        public bool errorLabelVisible
        {
            set
            {
                errorLabel.Visible = value;
            }
        }

        public string resultField
        {
            get
            {
                return resultTextBox.Text;
            }
            set
            {
                resultTextBox.Text = value;
            }
        }

        public string edgeValue
        {
            get
            {
                return edgeTextBox.Text;
            }
        }

        public string radiusValue
        {
            get
            {
                return radiusTextBox.Text;
            }
        }

        public string directionValue
        {
            get
            {
                return directionTextBox.Text;
            }
        }

        public string errorValue
        {
            set
            {
                errorLabel.Text = value;
            }
        }

        public string logText
        {
            get
            {
                return logRichTextBox.Text;
            }
            set
            {
                logRichTextBox.Text = value;
            }
        }

        public bool logRichTextBoxVisible
        {
            set
            {
                logRichTextBox.Visible = value;
            }
        }

        public event Action cubeButtonPressed;
        public event Action coneButtonPressed;
        public event Action cylinderButtonPressed;
        public event Action sphereButtonPressed;
        public event Action calculateButtonPressed;
        public event Action readLogButtonPressed;
        public event Action<bool> loggerStateChanged;

        public View()
        {
            InitializeComponent();
            Presenter presenter = new Presenter(this, new FileLogger());
        }

        private void cubeButton_Click(object sender, EventArgs e)
        {
            cubeButtonPressed();
        }

        private void coneButton_Click(object sender, EventArgs e)
        {
            coneButtonPressed();
        }

        private void cylinderButton_Click(object sender, EventArgs e)
        {
            cylinderButtonPressed();
        }

        private void sphereButton_Click(object sender, EventArgs e)
        {
            sphereButtonPressed();
        }

        private void resultButton_Click(object sender, EventArgs e)
        {
            calculateButtonPressed();
        }

        private void readLogButton_Click(object sender, EventArgs e)
        {
            readLogButtonPressed();
        }

        private void fileLoggerRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (sender is RadioButton)
            {
                RadioButton loggerButton = (RadioButton)sender;
                loggerStateChanged(loggerButton.Checked);
            }
        }

        public ILogger getFileLogger()
        {
            return new FileLogger();
        }

        public ILogger getHTMLLogger()
        {
            return new HTMLLogger();
        }
    }
}
